<template>
	<view class="wrapper" @click="toDetail" style="position:relative;width:  320rpx;">
		<view class="w-left">
			<fu-image :src="info.thumb" mode="aspectFill" lazy-load class="goods-img" width=" 320rpx" height=" 320rpx" radius="8"></fu-image>
		</view>
		<view style="height: 15rpx;">
			
		</view>
		<!-- <view class="newStyle" v-if="info.is_new == 1"> <text class="cuIcon-hotfill"></text> 新品推荐</view> -->
		<view class="w-right flex flex-direction justify-between ">
			<view class="name">{{info.name}}</view>
			<view class="address flex align-center">
				<view class="left flex align-center overHidden" @click.stop="toShop">
					<image src="https://xcxadmin.jgwxch.com/h5img/images/addr-2.png" class="icon"></image>
					<text class="addr text-cut">{{info.store_name}}</text>
				</view>
			</view>
			<view style="height: 15rpx;">
				
			</view>
			<!-- <view class="number flex">
				<view class="flex align-center item">
					<image src="https://xcxadmin.jgwxch.com/h5img/images/see.png" class="icon"></image>
					<text class="num">{{info.click || 0}}</text>
				</view>
				<view class="flex align-center item">
					<image src="https://xcxadmin.jgwxch.com/h5img/images/003.png" class="icon"></image>
					<text class="num">{{info.bargain || 0}}</text>
				</view>
			</view> -->
			<view class="bottom flex justify-between">
				<view class="left flex flex-wrap">
					<text class="text-price" style="margin-right: 8rpx;">{{info.shop_price}}</text>
					<text class="text-through">¥{{info.market_price}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	props: {
		icode:{
			type: String,
			default: ''
		},
		info: {
			type: Object,
			default() {
				return {}
			}
		},
		showBtn: {
			type: Boolean,
			default: true
		}
	},
	data() {
		return {
			
		}
	},
	methods: {
		// 分享到微信
		shareWx(info){
			console.log('分享',`/pages/goods/goodsdetail/goods-detail/index?sku_id=0&goods_id=${info.id}&type=share&invite_code=${this.icode}`);
			uni.share({
				provider:'weixin',
				scene: "WXSceneSession",
				type: 5,
				title: `原价¥${info.market_price},现价¥${info.shop_price}!【${info.name}】${info.store_name}`,
				// href:`https://xcxadmin.jgwxch.com/h5/index.html#/pages/goods/goodsdetail/goods-detail/index?sku_id=0&goods_id=${info.id}`,
				// summary: `原价¥${info.market_price},现价¥${info.shop_price}!【${info.name}】${info.store_name}`,
				imageUrl: info.thumb,
				miniProgram: {
				    id: 'gh_0fbfb5730c34',
				    path: `/pages/goods/goodsdetail/goods-detail/index?sku_id=0&goods_id=${info.id}&type=share&invite_code=${this.icode}`,
				    // path: `/pages/goods/sharePages/sharePages?sku_id=0&goods_id=${info.id}&type=share&invite_code=${this.icode}`,
				    type: 0,
				    webUrl: 'http://uniapp.dcloud.io'
				},
				success: function (res) {
					console.log("success:" + JSON.stringify(res));
				},
				fail: function (err) {
					console.log("fail:" + JSON.stringify(err));
				}
			});
		},
		toDetail() {
			this.$emit('onClick')
			this.$urouter.navigateTo({
			  url: '/pages/goods/goodsdetail/goods-detail/index',
			  params: {
			    sku_id: this.info.sku_id || 0,
			    goods_id: this.info.id
			  }
			});
		},
		kanjia() {
			this.$emit('kanjia', this.info)
		},
		qingguang() {
			if (this.info.stock == 0) {
				// this.$message.info('该商品暂无库存')
				return;
			}
		},
		toShop() {
			let location = this.$store.state.location
			// uni.openLocation({
			// 	latitude: location.latitude,
			// 	longitude: location.longitude,
			// 	success: res => {
			// 		console.log(res)
			// 	},
			// 	fail: err => {
			// 		console.log(err)
			// 	}
			// })
		}
	}
}
</script>

<style lang="scss" scoped>
	.newStyle{
		position: absolute;
		left: 10rpx;
		top: 40rpx;
		color: #fff;
		font-size: 24rpx;
		padding: 0 6rpx ;
		border-radius: 8rpx;	
		background-color: #FF6F27;
		// animation:flicker 1s infinite;
		// animation-direction: alternate;
	}
	@keyframes flicker{
		0%{
			opacity: 1;
		}
		100%{
			opacity: 0;
		}
	}
.wrapper {
	padding: 16rpx 0 0;
	// border-bottom: 1rpx solid #eee;
	display: flex;
	flex-direction: column;
	width:  350rpx;
	height: 500rpx;
	background-color: #fff;
	.w-left {
		flex-shrink: 0;
		.goods-img {
			width: 240rpx;
			height: 240rpx;
			border-radius: 8rpx;
		}
	}
	.w-right {
		margin-left: 8rpx;
		flex: 1;
		overflow: hidden;
		.name {
			font-size: 28rpx;
			font-weight: bold;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			overflow: hidden;
			word-break: break-all;
			-webkit-line-clamp: 2;
		}
		.address {
			margin-top: 16rpx;
			.left {
				flex: 1;
				.icon {
					flex-shrink: 0;
					width: 24rpx;
					height: 24rpx;
					margin-right: 16rpx;
				}
				.addr {
					font-size: 22rpx;
					color: #999;
				}
			}
			.right {
				font-size: 20rpx;
				color: #999;
				flex-shrink: 0;
			}
		}
		.number {
			margin-top: 8rpx;
			.item {
				margin-right: 64rpx;
				font-size: 22rpx;
				color: #999;
				.icon {
					width: 24rpx;
					height: 24rpx;
					margin-right: 24rpx;
				}
			}
		}
		.bottom {
			align-items: flex-end;
			.left {
				align-items: baseline;
			}
			.text-price {
				color: #FF5C5C;
				font-size: 36rpx;
				font-weight: bold;
			}
			.text-through {
				font-size: 24rpx;
				color: #999;
			}
			.right {
				border-radius: 28rpx;
				.btn {
					min-width: 105rpx;
					height: 56rpx;
					text-align: center;
					line-height: 56rpx;
					font-size: 20rpx;
					color: #fff;
					box-sizing: border-box;
					background-color: #FF6F27;
					padding: 0 8rpx;
				}
				.btn-left {
					border-radius: 28rpx 0 0 28rpx;
					border-right: 1rpx solid #eee;
				}
				.btn-right {
					border-radius: 0 28rpx 28rpx 0;
				}
				.btn2 {
					width: 140rpx;
					height: 56rpx;
					text-align: center;
					line-height: 56rpx;
					font-size: 28rpx;
					color: #fff;
					box-sizing: border-box;
					background-color: #FF6F27;
					border-radius: 28rpx;
				}
				.share {
					background-color: rgba(255, 111, 39, 0.10);
					border: 1rpx solid #FF6F27;
					color: #FF6F27;
				}
				.over-btn {
					background-color: #999;
				}
			}
		}
	}
}
</style>
